{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Second Partial (Solved).ipynb", "provenance": [], "toc_visible": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "f5X9iaV2tFbX" }, "source": [ "# Production Mix of Pharma\n", "## Problem definition\n", "Cheston Pharmaceuticals manufactures two different products. The company has conducted different studies to estimate the demand curve of their products, to learn the relationship between price and demand. The company has build a linear model that has proven to be accurate enough in the price range of interest for the company. Let us note the linear model as: \n", "\n", "$d_j = -\\theta_j*p_j+\\hat\\theta_j \\quad p_j=[m_j,M_j], \\forall j = [1,2]$\n", "\n", "Where $d_j$ is the total units of product $j$ manufactured, $p_j$ is the price of product $j$ and $\\theta_j$ and $\\hat\\theta_j$ are the parameters of the linear models for the curve of demand of product $j$. The price of product $j$ must be in the range of interest, that is, greater or equal than the minimum price $m_j$ and lower or equal than the maximum $M_j$.\n", "\n", "Both products incorporate a critical compound for which the company has limited resources to produce. The total production capacity of the company for the compound in the planning period is C (milligrams). A unit of product $j$ contains $r_j$ milligrams of the critical compound.\n", "\n", "Let us assume that the production costs of product $j$ can be neglected. \n", "\n", "**a.** Write a Non-Linear Programming problem to calculate the optimal production mix (number of units to produce of each product) that maximises the revenues in the planning period." ] }, { "cell_type": "markdown", "metadata": { "id": "8TvYsfg0eJ2P" }, "source": [ "The optimization problem can be defined as:\n", "\n", "$\\max z = \\sum_j{d_j*p_j}$\n", "\n", "s.t.\n", "\n", "$p_j \\geq m_j \\quad \\forall j$\n", "\n", "\n", "$p_j \\leq M_j \\quad \\forall j$\n", "\n", "\n", "$\\sum_j{d_j*r_j} \\leq C$\n", "\n", "\n", "Applying the demand curve:\n", "\n", "$p_j = \\frac{d_j - \\hat\\theta_j}{-\\theta_j} = -\\frac{1}{\\theta_j}*d_j + \\frac{\\hat\\theta_j}{\\theta_j}$\n", "\n", "yields:\n", "\n", "$\\max z = \\sum_j{\\left(-\\frac{1}{\\theta_j}*d_j^2 + \\frac{\\hat\\theta_j}{\\theta_j}*d_j\\right)}$\n", "\n", "\n", "$s.t.$\n", "\n", "$\\frac{1}{\\theta_j}*d_j - \\frac{\\hat\\theta_j}{\\theta_j} + m_j \\leq 0 \\quad \\forall j$\n", "\n", "$-\\frac{1}{\\theta_j}*d_j + \\frac{\\hat\\theta_j}{\\theta_j} - M_j \\leq 0 \\quad \\forall j$\n", "\n", "$\\sum_j{d_j*r_j} - C \\leq 0$" ] }, { "cell_type": "markdown", "metadata": { "id": "QfR2WlFQhgPk" }, "source": [ "**b** Write down the Lagrangian " ] }, { "cell_type": "markdown", "metadata": { "id": "QZja1WLshs8i" }, "source": [ "The Lagrangian is: \n", "\n", "$L(d_j, \\lambda_i) = \\sum_j{\\left(-\\frac{1}{\\theta_j}*d_j^2 + \\frac{\\hat\\theta_j}{\\theta_j}*d_j\\right)} + \\lambda_1*(\\frac{1}{\\theta_1}*d_1 - \\frac{\\hat\\theta_1}{\\theta_1} + m_1) + \\lambda_2*(\\frac{1}{\\theta_2}*d_2 - \\frac{\\hat\\theta_2}{\\theta_2} + m_2) + ...$\n", "\n", "$... + \\lambda_3*(-\\frac{1}{\\theta_1}*d_1 + \\frac{\\hat\\theta_1}{\\theta_1} - M_1) + \\lambda_4*(-\\frac{1}{\\theta_2}*d_2 + \\frac{\\hat\\theta_2}{\\theta_2} - M_2) + \\lambda_5(\\sum_j{d_j*r_j} - C)$ " ] }, { "cell_type": "markdown", "metadata": { "id": "tPyhDcQFo4nr" }, "source": [ "**c** Write down the Kuhn-Tucker conditions:\n", "\n", "**Gradient condition**\n", "\n", "$\\nabla L(d_j, \\lambda_i) = 0$\n", "\n", "$-\\frac{2}{\\theta_1}*d_1 + \\frac{\\hat\\theta_1}{\\theta_1} + \\frac{\\lambda_1}{\\theta_1} - \\frac{\\lambda_3}{\\theta_1} + \\lambda_5*r_1 = 0$\n", "\n", "$-\\frac{2}{\\theta_2}*d_2 + \\frac{\\hat\\theta_2}{\\theta_2} + \\frac{\\lambda_2}{\\theta_2} - \\frac{\\lambda_4}{\\theta_2} + \\lambda_5*r_2 = 0$\n", "\n", "**Orthogonality condition**\n", "\n", "$\\lambda_1*(\\frac{1}{\\theta_1}*d_1 - \\frac{\\hat\\theta_1}{\\theta_1} + m_1) = 0$\n", "\n", "$\\lambda_2*(\\frac{1}{\\theta_2}*d_2 - \\frac{\\hat\\theta_2}{\\theta_2} + m_2) = 0$\n", "\n", "$\\lambda_3*(-\\frac{1}{\\theta_1}*d_1 + \\frac{\\hat\\theta_1}{\\theta_1} - M_1) = 0$\n", "\n", "$\\lambda_4*(-\\frac{1}{\\theta_2}*d_2 + \\frac{\\hat\\theta_2}{\\theta_2} - M_2) = 0$\n", "\n", "$\\lambda_5(\\sum_j{d_j*r_j} - C) = 0$\n", "\n", "**Feasibility condition**\n", "\n", "$\\frac{1}{\\theta_j}*d_j - \\frac{\\hat\\theta_j}{\\theta_j} + m_j \\leq 0 \\forall j$\n", "\n", "$-\\frac{1}{\\theta_j}*d_j + \\frac{\\hat\\theta_j}{\\theta_j} - M_j \\leq 0 \\forall j$\n", "\n", "$\\sum_j{d_j*r_j} - C \\leq 0$\n", "\n", "**Non-negativity condition**\n", "\n", "$p_j \\geq 0 \\quad \\forall j=[1,2]$\n", "\n", "$\\lambda_i \\leq 0 \\forall i=[1,5]$" ] }, { "cell_type": "markdown", "metadata": { "id": "7FHtYcskrtcJ" }, "source": [ "**d.** Write down the Hessian matrix and the Hessian determinants. In case that you find a critical point, can you determine if it is a local or a global maximum? Motivate your response." ] }, { "cell_type": "markdown", "metadata": { "id": "M0xhgKzUrz4Q" }, "source": [ "$H = \\begin{bmatrix}\n", "-\\frac{2}{\\theta_1} & 0 \\\\\n", "0 & -\\frac{2}{\\theta_2}\n", "\\end{bmatrix}$\n", "\n", "$h_1 = -\\frac{1}{\\theta_1}$\n", "\n", "$h_2 = \\frac{1}{\\theta_1*\\theta_2}$\n", "\n", "According to Sylvester's criterion, the Hessian is definite positive and the point is a global maximum for all $\\theta_j > 0$. This is because the first determinant is negative ($h_1 < 0$) and the second determinant is positive ($h_2 > 0$). Note that assuming $\\theta_j > 0$ is reasonable since the demand curve is downward sloping, which implies that $\\theta_j$ must be positive." ] } ] }